/*
  Copyright 1996-2003
  Simon Whiteside

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  $Id: DynamicTreeNode.java,v 1.2 2003/02/24 19:57:01 simkin_cvs Exp $
*/

package simkin.examples.dynamic_treenode;
import simkin.*;

/**
 * This programs shows how to use dynamic treenodes.
 * It loads a script called dynamic.dat which adds data to a global treenode object called "Data"
*/
public class DynamicTreeNode  {
    /**
     * Entry point for the DynamicTreeNode application. 
     */
    static public void main(String[] args){
	try{
	    // Create an interpreter and a context
	    Interpreter interp=new Interpreter();
	    ExecutableContext ctxt=new ExecutableContext(interp);
	    
	    // Create a treenode which can be added to
	    TreeNodeObject obj=new TreeNodeObject("",new TreeNode());
	    obj.setAddIfNotPresent(true);
	    
	    // Make this a global variable called "Data"
	    interp.addGlobalVariable("Data",obj);
	    
	    // create a ScriptedExecutable to execute the "dynamic.dat" script
	    ScriptedExecutable executable=new ScriptedExecutable("dynamic.dat");
	    
	    // and call the "main" method
	    executable.method("main",null,ctxt);
	}catch(Exception e){
	    e.printStackTrace();
	}
    }
}
